home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Loadstar Extras 3
/
Ex3side1.d64
/
source convert.s
< prev
next >
Wrap
Text File
|
2022-08-28
|
8KB
|
849 lines
acptr =$ffa5
open =$ffc0
readst =$ffb7
setlfs =$ffba
setnam =$ffbd
load =$ffd5
getin =$ffe4
clrchn =$ffcc
close =$ffc3 ;a
ciout =$ffa8
chrin =$ffcf
chkout =$ffc9 ;x
chkin =$ffc6 ;x
stop =$ffe1
udtim =$ffea
plot =$fff0
chrout =$ffd2
color'pointer =243
screen'line'pointer =209
print'number =$bdcd ;x,a
clear'line =59903
background =53281
border =53280
unlisten =$ffae
clall =$ffe7
.org $9000
.obj "@0:tools 9000"
;mem
jmp checker
jmp hex'read
jmp fill
jmp directory
jmp find
jmp screen'pet
jmp text'source
jmp binary'source
jmp clear'array
checker lda 199
sta condition
jsr get'string
jsr setnam
lda #2
jsr close
jsr get'number
tya
tax
lda #2
ldy #2
jsr setlfs
jsr open
jsr clrchn
ldx #2
jsr chkin
lda #0
sta length
sta length+1
sta end'address
sta end'address+1
jsr getin
inc length
sta load'address
sta end'address
jsr readst
and #64
bne end
jsr getin
inc length
sta load'address+1
sta end'address+1
jsr readst
and #64
bne end
- jsr getin
inc length
bne +
inc length+1
jsr graph
+ inc end'address
bne +
inc end'address+1
+ jsr readst
and #64
bne end
beq -
end lda #2
jsr close
jsr clrchn
lda #13
jsr chrout
lda condition
sta 199
lda <load'text
ldy >load'text
jsr $ab1e
ldx load'address
lda load'address+1
jsr $bdcd
lda " "
jsr chrout
lda "("
jsr chrout
lda <load'address+1
sta 251
lda >load'address+1
sta 252
jsr print'hex
lda "-"
jsr chrout
lda <end'address+1
sta 251
lda >end'address+1
jsr print'hex
lda ")"
jsr chrout
lda <len'text
ldy >len'text
jsr $ab1e
ldx length
lda length+1
jsr $bdcd
rts
print'hex lda "$"
jsr chrout
jsr hex'convert
dec 251
lda 251
cmp #255
bne +
dec 252
+ jsr hex'convert
rts
hex'convert ldy #0
lda (251),y
tax
and #%11110000
lsr
lsr
lsr
lsr
tay
lda hex,y
jsr chrout
txa
and #%00001111
tay
lda hex,y
jsr chrout
rts
graph ldy index
cpy #7
bcc +
ldy #255
lda #29
jsr chrout
+ iny
sty index
lda reverse,y
sta 199
lda char,y
jsr chrout
lda #157
jsr chrout
rts
hex'read lda #0
sta 212
sta 199
lda #147
jsr chrout
jsr get'string
jsr setnam
jsr get'number
tya
tax
lda #2
tay
jsr setlfs
jsr open
jsr clrchn
ldx #2
jsr chkin
lda #0
sta counter
jsr getin
sta 251
jsr getin
sta 252
jsr print'position
read'file jsr getin
sta temp
jsr readst
and #66
bne end'o'file
jsr convert
lda #30
clc
adc counter
tay
lda temp
sta (209),y
lda 646
sta (243),y
inc counter
lda counter
cmp #8
bcc +
lda #0
sta counter
lda #13
jsr chrout
lda #8
clc
adc 251
sta 251
lda #0
adc 252
sta 252
jsr print'position
- lda 653
bne -
lda 197
cmp #63
beq end'o'file
+ jmp read'file
end'o'file lda #2
jsr close
jmp clrchn
print'position lda ":"
jsr chrout
dec flag
lda 252
sta temp
jsr convert
lda 251
sta temp ;fall through to convert
inc flag
convert lda temp
and #%11110000
lsr
lsr
lsr
lsr
tay
lda hex,y
jsr chrout
lda temp
and #%00001111
tay
lda hex,y
jsr chrout
bit flag
bmi +
lda " "
jsr chrout
+ rts
fill jsr get'number
sta 252
sty 251
jsr get'number
sta 254
sty 253
jsr get'number
sty temp
ldy #0
lda temp
- sta (251),y
inc 251
bne +
inc 252
+ ldx 252
cpx 254
bcc -
ldx 251
cpx 253
bcc -
beq -
rts
get'string jsr $aefd
jsr $ad9e
jsr $b6a3
ldx $22
ldy $23
rts
get'number jsr $aefd
jsr $ad8a
jsr $b7f7
rts
directory jsr get'string
jsr setnam
jsr get'number
tya
tax
lda #2
ldy #0
jsr setlfs
jsr open
jsr clrchn
ldx #2
jsr chkin
jsr getin
jsr getin
jsr getin
jsr getin
get'blocks jsr getin
sta 251
jsr getin
ldx 251
jsr print'number
lda " "
jsr chrout
jsr chrout
get'name lda 653
bne get'name
jsr getin
beq next'name
jsr chrout
jsr readst
and #66
bne end'dir
beq get'name
next'name jsr getin
beq end'dir
jsr getin
lda #13
jsr chrout
jmp get'blocks
end'dir lda #2
jsr close
jsr clrchn
rts
find lda #0;sys,file$,dev,string,and,or,buffer loc
sta flag
jsr get'string
jsr setnam
jsr get'number
tya
tax
lda #2
ldy #2
jsr setlfs
jsr open
jsr clrchn
ldx #2
jsr chkin
jsr get'string
stx 249
sty 250
sta length
jsr get'number
sty length+1;anding factor
jsr get'number
sty load'address;oring factor
jsr get'number
sta 252
sty 251
lda #1
clc
adc 251
sta 253
lda #0
adc 252
sta 254
fill'buffer ldy #0
- jsr getin
ora load'address
and length+1
sta (251),y
iny
cpy length
bne -
search ldy #0
- lda (249),y
ora load'address
and length+1
cmp (251),y
bne bump'buffer
iny
cpy length
bne -
found lda "y"
sta 631
lda #1
sta 198
search'out lda #2
jsr close
jmp clrchn
bump'buffer lda flag
bne end'search
ldy #0
- lda (253),y
sta (251),y
iny
cpy length
bne -
dey
jsr getin
and length+1
ora load'address
sta (251),y
jsr readst
and #66
sta flag
jmp search
end'search lda "n"
sta 631
lda #1
sta 198
jmp search'out
;sys name in,device,name out,device
screen'pet lda #0
sta eof
jsr clall
jsr get'string
jsr setnam
jsr get'number
sty device
lda #2
ldx device
ldy #2
jsr setlfs
jsr open
jsr get'string
jsr setnam
jsr get'number
sty device+1
lda #1
ldx device+1
ldy #1
jsr setlfs
jsr open
jsr clrchn
ldx #2
jsr chkin
ldx #1
jsr chkout
lda <$8000
jsr chrout
lda >$8000
jsr chrout
get'byte ldx #2
jsr chkin
jsr getin
sta temp
jsr readst
and #66
sta eof
ldx #1
jsr chkout
lda temp
cmp #31
beq back'arrow
cmp #91
beq shift'plus
jsr aconvert
jsr chrout
check lda eof
beq get'byte
lda #1
jsr close
lda #2
jsr close
jmp clrchn
back'arrow lda #13
jsr chrout
jmp check
shift'plus lda "{SHIFT-+}"
jsr chrout
jmp check
aconvert sta store; screen code to ASCII
and #$3f
asl store
bit store
bpl +
ora #128
+ bvs +
ora #$40
sta store
+ rts
;sys name in,device,name out,device
text'source lda #0
sta eof
jsr clall
jsr get'string
jsr setnam
jsr get'number
sty device
lda #2
ldx device
ldy #2
jsr setlfs
jsr open
jsr get'string
jsr setnam
jsr get'number
sty device+1
lda #1
ldx device+1
ldy #1
jsr setlfs
jsr open
jsr clrchn
ldx #2
jsr chkin
ldx #1
jsr chkout
jsr doasc
get'byteii ldx #2
jsr chkin
jsr getin
sta temp
jsr readst
and #66
sta eof
ldx #1
jsr chkout
lda temp
jsr write'bytes
scheck lda eof
beq get'byteii
lda #13
jsr chrout
jsr chrout
lda #1
jsr close
lda #2
jsr close
jmp clrchn
write'bytes ldx #1
jsr chkout
lda temp
cmp #13
beq endline
cmp #34
bne +
jsr do'quote
rts
+ jsr chrout
rts
endline ldx #1
jsr chkout
ldy #0
- lda endtext,y
beq doasc
jsr chrout
iny
bne -
doasc ldx #1
jsr chkout
ldy #0
- lda astext,y
beq +
jsr chrout
iny
bne -
+ rts
do'quote ldx #1
jsr chkout
ldy #0
- lda quote'text,y
beq +
jsr chrout
iny
bne -
+ rts
;sys name in,device,name out,device
binary'source lda #0
sta eof
jsr clall
jsr get'string
jsr setnam
jsr get'number
sty device
lda #2
ldx device
ldy #2
jsr setlfs
jsr open
jsr get'string
jsr setnam
jsr get'number
sty device+1
lda #1
ldx device+1
ldy #1
jsr setlfs
jsr open
jsr clrchn
ldx #2
jsr chkin
jsr getin
jsr getin
lda #7
sta counter
jsr dobyt
get'byteiii ldx #2
jsr chkin
jsr getin
sta temp
jsr readst
and #66
sta eof
ldx #1
jsr chkout
lda temp
jsr write'hbytes
bcheck lda eof
beq get'byteiii
lda #13
jsr chrout
jsr chrout
lda #1
jsr close
lda #2
jsr close
jmp clrchn
write'hbytes ldx #1
jsr chkout
jsr convertii
dec counter
bmi endbline
lda eof
bne +
lda ","
jsr chrout
+ rts
endbline lda #7
sta counter
ldx #1
jsr chkout
lda #13
jsr chrout
dobyt ldx #1
jsr chkout
ldy #0
- lda byttext,y
beq +
jsr chrout
iny
bne -
+ rts
convertii lda "$"
jsr chrout
lda temp
and #%11110000
lsr
lsr
lsr
lsr
tay
lda hex,y
and #127
jsr chrout
lda temp
and #%00001111
tay
lda hex,y
and #127
jsr chrout
+ rts
clear'array ldy <1024
lda >1024
sty 251
sta 252
ldx #3
- lda #1
sec
sbc (251),y
sta (251),y
iny
bne -
inc 252
dex
bpl -
lda <1024
sta $14
lda >1024
sta $15
ldx #3
ldy #0
sty temp
- lda ($14),y
bne flag'low
back iny
bne -
inc $15
dex
bpl -
rts
flag'low bit temp
bmi high
low dec temp
tya
pha
clc
adc $14
sta 251
lda #0
adc $15
sta 252
pla
tay
jmp back
high tya
pha
clc
adc $14
sta 253
lda #0
adc $15
sta 254
pla
tay
jmp back
rts
endtext .byt 34:.asc ":.byte 13":.byt 13,0
astext .asc ".asc ":.byt 34,0
byttext .asc ".byte ":.byt 0
quote'text .byt 34:.asc ":.byt 34:.asc ":.byte 34,0
device .buf 2
store .byt 0
eof .buf 2
load'address .buf 2
length .buf 2
end'address .word 0
hex .asc "0123456789ABCDEF"
load'text .asc " load:":.byt 0
len'text .asc " bytes:+":.byt 0
end'text .asc "end:":.byt 0
char .byt 165,180,181,161,182,170,167,32
reverse .byt 0,0,0,0,1,1,1,1
index .byt 0
condition .byt 0
te